<template>
  <div class="home">

    <el-button type='danger' @click="getData">获取菜单</el-button>
    <el-button type='danger' @click="getAction">获取菜单2</el-button>
    <ul>
      <li v-for="(menu,index) in myList" :key="index">{{menu.title}}</li>
    </ul>
  </div>
</template>

<script>
// @ is an alias to /src    @ 代表src目录下
import HelloWorld from '@/components/HelloWorld.vue'
import {mapGetters} from 'vuex'
export default {
  name: 'Home',
  components: {
    HelloWorld
  },
  computed:{
    ...mapGetters([
      'myList'
    ])
  },
  methods: {
    getData(){
      this.http('/menulist')
      .then(res => {
        // console.log(res);
      this.$store.commit('getMenu',res.list)
      })
    },
    getAction(){
      this.$store.dispatch('getMenuInfo')
    }
  }
}
</script>
